<?php
class Lib_Setting
{
    private static $instance;
    private static $setting = NULL;

    private function __construct()
    {
        $this->load_data();
    }

    public static function getInstance()
    {
        if(!isset(self::$instance))
        {
            self::$instance = new Lib_Setting();
        }
        
        return self::$instance;
    }

    public static function get($key)
    {
        if(self::$setting == NULL)
        {
            $data = ConfigurationTable::getInstance()->findAll();
            if($data !== NULL)
            {
                foreach($data as $obj)
                {
                    self::$setting[$obj->key] = $obj->value;
                }
            }
        }

        if(isset(self::$setting[$key]) == TRUE)
        {
            return self::$setting[$key];
        }
        
        return FALSE;
    }
}